package com.zj.jd_unlock

import android.view.MotionEvent
import android.widget.ImageView
import com.zj.jd_unlock.databinding.ActivityMainBinding

class LinkPresenter(val target:ILinkVIew) {
    //记录上一次被点亮的点的视图
    private var lastSelectedDot: ImageView? = null
    //模拟密码
    private val password = "123"
    //记录所有点亮的控件
    private val selectedArray = arrayListOf<ImageView>()
    //记录密码
    private val passwordBuilder = StringBuilder()
    //保存所有的模型对象
    var modelsArray = arrayListOf<LinkModel>()
    fun down_Action(event: MotionEvent){

    }

    fun move_Action(event:MotionEvent){

    }
    fun up_Action(binding: ActivityMainBinding){
        //判断密码是否正确
        if(password == passwordBuilder.toString()){
            binding.alertTitle.text = "密码正确"
            }
        else{
        binding.alertTitle.text = "密码错误"
            for (aView in selectedArray) {
                for (model in modelsArray) {
                    if (model.view == aView){
                        target.changeImage(model,false)
                        break
                    }
                }
            }
        }
    }
}
